package com.android.kmlmrg.services.web;


import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.os.AsyncTask;
import android.util.Log;

public final class AuthentificationImpl extends AsyncTask<String, Integer, String> {
	private static final String METHOD_NAME = "connexion";
	private static final String NAMESPACE = "http://webservice/";
	/**LOG**/
	private static final  String LOG_TAG = AuthentificationImpl.class.getName();
	
    public  String connexion( String arg0, String arg1) throws Exception {
		Log.i(LOG_TAG, "START - String connexion( String arg0, String arg1)");
    	SoapObject _client = new SoapObject (NAMESPACE, METHOD_NAME);
        _client.addProperty("arg0", arg0);
        _client.addProperty("arg1", arg1);
        SoapSerializationEnvelope _envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        _envelope.bodyOut = _client;
        HttpTransportSE _ht = new HttpTransportSE(Configuration.getWsUrl());
        _ht.call("", _envelope);
        String vReponse =  (String )_envelope.getResponse();
		Log.i(LOG_TAG, "END - String connexion return " + vReponse);
        return vReponse;
    }

	@Override
	protected String doInBackground(String... params) {
		String arg0 = params[0];
		String arg1 = params[1];
		String vResult="ko";
		try {
			 vResult = connexion(arg0, arg1);
		} catch (Exception e) {
			
			Log.i(LOG_TAG, "Erreur");
			e.printStackTrace();
		}
		return vResult;
	}

	@Override
	protected void onPostExecute(String result) {
		// TODO Auto-generated method stub
		super.onPostExecute(result);
	}
	
	


}
